//
//  HMBaseTableController.m
//  weibo
//
//  Created by apple on 2016/11/14.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "HMBaseTableController.h"
#import "HMOAuthViewController.h"
#import "HMAccountViewModel.h"
@interface HMBaseTableController ()<HMLoginViewDelegate>

@end

@implementation HMBaseTableController
-(BOOL)isOnlogin{
    if (!_isOnlogin) {
        _isOnlogin = [HMAccountViewModel shared].isSucceedLogion;
    }
    return _isOnlogin;
}
-(UINavigationBar *)naviBar{
    if (!_naviBar) {
        _naviBar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 64)];
        _naviBar.backgroundColor = [UIColor orangeColor];
    }
    return _naviBar;
}
-(UINavigationItem *)naviItem{
    if (!_naviItem) {
        _naviItem = [[UINavigationItem alloc]init];
    }
    return _naviItem;
}

-(void)loadView{
//    [super loadView];
    if (self.isOnlogin) {
        [super loadView];
        [self setupMainView];
    }else{
        HMLoginView *loginV = [[HMLoginView alloc]init];
        _loginV = loginV;
        self.view = loginV;
        _loginV.delegate = self;
        [self setupNavigationBar];
    }
}
-(void)clickEnterBtn{
    HMOAuthViewController *vc = [[HMOAuthViewController alloc]init];
    UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:vc];
    [self presentViewController:navi animated:YES completion:nil];
    
    NSLog(@"登入了");
}
-(void)clickRegisterBtn{
    NSLog(@"注册了");
}
-(void)setupMainView{
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0,0, ScreenWidth, ScreenHeight) style:UITableViewStylePlain];
    _tableView.contentInset = UIEdgeInsetsMake(44, 0, 0, 0);
    _tableView.delegate = self;
    _tableView.dataSource = self;

    [self.view addSubview:self.tableView];
    [self setupNavigationBar];
}

-(void)setupNavigationBar{
    [self.navigationController.navigationBar setHidden:YES];
//   self.navigationController.navigationBar
    [self.view addSubview:self.naviBar];
    self.naviItem.title = self.navigationItem.title;
    self.naviBar.items = @[self.naviItem];
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    return [[UITableViewCell alloc]init];
}

@end
